package com.sduept.chargeRec;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Date;

import org.tio.core.intf.Packet;

import com.sduept.zj103.model.Apci;

public class CdzlbPacket extends Packet {
    private static final long serialVersionUID = -172060606924066412L;

    public static final String CHARSET = "UTF-8";
    //private byte[] body=new byte[60];
    private byte[] macAddress=new byte[6];
    private byte[] originMac=new byte[6];
    private int packetLength = 0 ;
    private short packetType = 0 ;
    private short code = 0;
    private byte[] message=new byte[8];
    private byte[] spare=new byte[10];
    private short comCounter=0;
    private short packetNumber=0;
    private short packetCounter=0;
    private short packetResend=0;
    private short comResend=0;
    private int dataLength=0;
    private short pointLogo=0;
    private byte[] spare2=new byte[6];
    private byte[] data;
	public byte[] getMacAddress() {
		return macAddress;
	}
	public void setMacAddress(byte[] macAddress) {
		this.macAddress = macAddress;
	}
	public byte[] getOriginMac() {
		return originMac;
	}
	public void setOriginMac(byte[] originMac) {
		this.originMac = originMac;
	}
	public int getPacketLength() {
		return packetLength;
	}
	public void setPacketLength(int packetLength) {
		this.packetLength = packetLength;
	}
	public short getPacketType() {
		return packetType;
	}
	public void setPacketType(short packetType) {
		this.packetType = packetType;
	}
	public short getCode() {
		return code;
	}
	public void setCode(short code) {
		this.code = code;
	}
	public byte[] getMessage() {
		return message;
	}
	public void setMessage(byte[] message) {
		this.message = message;
	}
	public byte[] getSpare() {
		return spare;
	}
	public void setSpare(byte[] spare) {
		this.spare = spare;
	}
	public short getComCounter() {
		return comCounter;
	}
	public void setComCounter(short comCounter) {
		this.comCounter = comCounter;
	}
	public short getPacketNumber() {
		return packetNumber;
	}
	public void setPacketNumber(short packetNumber) {
		this.packetNumber = packetNumber;
	}
	public short getPacketCounter() {
		return packetCounter;
	}
	public void setPacketCounter(short packetCounter) {
		this.packetCounter = packetCounter;
	}
	public short getPacketResend() {
		return packetResend;
	}
	public void setPacketResend(short packetResend) {
		this.packetResend = packetResend;
	}
	public short getComResend() {
		return comResend;
	}
	public void setComResend(short comResend) {
		this.comResend = comResend;
	}
	public int getDataLength() {
		return dataLength;
	}
	public void setDataLength(int dataLength) {
		this.dataLength = dataLength;
	}
	public short getPointLogo() {
		return pointLogo;
	}
	public void setPointLogo(short pointLogo) {
		this.pointLogo = pointLogo;
	}
	public byte[] getSpare2() {
		return spare2;
	}
	public void setSpare2(byte[] spare2) {
		this.spare2 = spare2;
	}
	public byte[] getData() {
		return data;
	}
	public void setData(byte[] data) {
		this.data = data;
	}
	
	// 报文档案
	public void makeArc() {
        Date now = new Date();
        long msecond = now.getTime();
        long second = msecond/1000;
        msecond = msecond-second*1000;
        setCode((short) 0x46);
        setPacketLength(60+36);
        setDataLength(36);
        ByteBuffer byteBuffer = ByteBuffer.allocate(36);
        byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
        byteBuffer.putShort((short) 0xac02);
        byteBuffer.putInt((int) second);
        byteBuffer.putInt((int) msecond);
        byteBuffer.putInt((int) second);
        byteBuffer.putInt((int) msecond);
        byteBuffer.putInt((int) 123);
        byteBuffer.putShort((short) 12);
        setData(byteBuffer.array());
	}
}